﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SQLServerHealthCheck.Model;

namespace PlayGround
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnPlay_Click(object sender, EventArgs e)
        {

            HealthCheckDataContext dc = new HealthCheckDataContext(System.Configuration.ConfigurationManager.AppSettings["ConnectionStringSSHCDatabase"].ToString());
            Issue issue;

            var Qry = from t in dc.Tables
                      where t.Indexes.Count(i => i.IS_PK == true) > 0 
                      
                      select t;  


            try
            {
                if (Qry.Count()!= 0)
                {
                    dbgResults.DataSource = Qry;
                }
                else { MessageBox.Show("No Database Records matches the Specified Query"); }
            }
            catch (Exception sqlex)
            {

                MessageBox.Show(sqlex.Message);
            }
            


       
       }
    
    
    
    }
}
